There are a number of ways that peeking into memory can be of value in a hypercard stack. The examples that follow are only meant to be suggestive and not exhaustive. In fact, peeking into the right locations can be as effective as using a specially designed XFCN or XCMD. There are some reasonable arguments against using peeks in some circumstances, particularly if the significance of a particular location could change at some later date. The addresses mentioned here are safe in the sense that it is unlikely that Apple will change their meanings in the future.
1. Status Checks
By peeking into 8D2 you can tell if the cursor is visible or not.
For example, try the following script in some card.
on idle
if peekbyte("8D2")="01" then play "boing"
end idle
Now, whenever the cursor becomes invisible, a boing will sound.
2. Parameter Settings
You can check the current setting of the volume (as set by the control panel desk accessory) by peeking into the byte at address 260.
3. Checking For Keys
You can check for a particular keypress by peeking into the byte at address 185. This address contains the ASCII code for any current character typed from the keyboard. Thus if peekbyte(185)="0D" then the return key is being held down.
Moreover, you can distinguish the keys on the keypad from those on the keyboard by peeking into the keycode location (184). The information you get here is not as reliable as the ASCII value since it is dependent upon the keyboard that is hooked to the Mac. We are assuming here that you are using a MAC+ with standard keyboard. Other configurations could be different.
For example, if peekbyte(184)="4D", then the / key on the keypad is being pressed, while if peekbyte(184)="2C", then the / key on the keyboard is being pressed. Both of these keys produce the ASCII code of 2F and so whenever either is pressed, peekbyte(185) will return the value of "2F". If you were to try to implement this technique into a script, you should probably check both the ASCII code and keycode. This method is not entirely reliable since keycodes differ on some keyboards (particularly foreign ones). However, the character code in location 185 is reliable regardless of the keyboard.
You can also check the type of keyboard attatched to the Macintosh by peeking into location 21E. If the byte stored in 21E is 0B, then this is the standard Mac+ keyboard with a numeric keypad. If the value stored there is 03, then the keyboard is the old classic keyboard with no numeric keypad. You can determine the value returned for another keyboard by simply hooking it to the Mac and peeking into 21E with the peekbyte XFCN.
Detecting foreign boards is a bit trickier. A very good reference to the low-level details of Mac keyboards can be found in an excellent pair of articles by Joel West entitled "Be a Keyboard Sleuth" in MacTutor magazine. The first of these articles appeared in the August 1986 issue of MacTutor.
Note too that you can check for the Caps Lock, Option key, Command key, etc by peeking into the contents of17B.
For example, if the value of peekbyte(H17B) is 2 then the Caps Lock is down and Shift and Option keys are up. If The value in 17B is odd, then the Shift key is down.